<?php
require_once 'Zend/Db/Table/Abstract.php';

class  Somi_Models_User extends Zend_Db_Table_Abstract 
{
	protected $_name='user';
	protected $_primary = 'user_id';
	#protected $_rowClass = 'user';
	#protected $_sequence  = true;
	#protected $_dependentTables = array('email');
	
	
	public function getFLname(){
        
        $userArr = array(0 => ' ');
        
        $user = $this->fetchAll()->toArray();
        foreach ($user as $value)
        {
            $userArr[$value["user_id"]] = $value["firstname"].','.$value["lastname"];
        }
        
        return $userArr;    
        
    }
    
    public function getTitel(){
    	
   		 # Starte den Datenbank
    	$db= Zend_Registry::get('db');
    	# die Beschreibungen(kopf zeile) von tabelle User laden
		$temp = $db->describeTable('user');
		# Lade die datentype (Enum)  
		$temp_enum=$temp['titel']['DATA_TYPE'];
		# Explode die Datatype 
		$temp=explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$temp_enum));
		
    	return $temp;
    	
    }
    
	public function getGender(){
    	
    	# Starte den Datenbank
    	$db= Zend_Registry::get('db');
    	# die Beschreibungen(kopf zeile) von tabelle User laden
		$temp = $db->describeTable('user');
		# Lade die datentype (Enum) 
		$temp_enum=$temp['gender']['DATA_TYPE'];
		# Explode die Datatype 
		$temp=explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$temp_enum));
		
    	return $temp;
    	
    }
    
	public function getRole(){
    	
    	# Starte den Datenbank
    	$db= Zend_Registry::get('db');
    	# die Beschreibungen(kopf zeile) von tabelle laden
		$temp = $db->describeTable('user');
		# Lade die datentype (Enum) 
		$temp_enum=$temp['role']['DATA_TYPE'];
		# Explode die Datatype 
		$temp=explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$temp_enum));
		
    	return $temp;
    	
    }
    
    public function getUser($id){
		
    	$user=$this->fetchRow('user_id='.$id);
    	return $user;
    }
    

	
}



?>